<template>
	<div class="tab-bar-item" @click="ItemClick">
		<div :style="activeStyle">
			<slot name="item"></slot>
		</div>
	</div>
</template>

<script>
	export default{
		name:"TabBarItem",
		props:{
			path:String,
			activeColor:{
				type:String,
				default:'#0077AA'
			}
		},
		data(){
			return{
			}
		},
		computed:{
			isActive(){
				return this.$route.path .indexOf(this.path) !== -1;
			},
			activeStyle(){
				return this.isActive ? {color:this.activeColor}:{};
			}
		},
		methods:{
			ItemClick(){
				this.$router.push(this.path)
			}
		},
	}
</script>

<style scoped>
	.tab-bar-item {
		flex: 1;
		text-align: center;
		height: 49px;
		font-size: 14px;
	}
	
	.active{
		color: #0077AA;
	}

</style>
